/**
 * Created by Administrator on 2017/3/31.
 */
$(function(){
    //搜索栏中搜索条件选择
    var indextype =[
        {"value":1,"text":"全文"},
        {"value":2,"text":"姓名"},
        {"value":3,"text":"意向岗位"}
    ];
    $("#keyword_type").select({
        optionData:indextype,
        css:'indexOptions',
        offset:Array(0,1),
        callback:function(){
            // $('.logoAndSearch .searchCont .select i').removeClass('active');
        }
    });

    //筛选栏中性别选择下拉框
    var sex = [
        {"value":0,"text":"性别不限"},
        {"value":1,"text":"男"},
        {"value":2,"text":"女"}
    ];
    var select1 = $("#sex").select({
        optionData:sex,//菜单选项数据
        callback:function(val,text){
            person_jump(sex_url,'sex',val);
        }//选择后的动作
    });

    //筛选栏中学历选择下拉框
    option_education.unshift({"text": "学历不限", "value": 0});
    var select2 = $("#education ").select({
        optionData:option_education,//菜单选项数据
        callback:function(val,text){
            person_jump(education_url,'education',val);
        }//选择后的动作
    });

    //筛选栏中居住地下拉框
    var homeaddress = areaForHomeAddress;
    var select3 = $("#homeaddress").select({
        optionData:homeaddress,//菜单选项数据
        callback:function(val,text){
            person_jump(homeaddress_url,'homeaddress',val);
        }//选择后的动作
    });
    //筛选栏中户籍下拉框
    var households = areaForHouseHolds;
    var select4 = $("#census").select({
        optionData:households,//菜单选项数据
        callback:function(val,text){
            person_jump(census_url,'census',val);
        }//选择后的动作
    });

    //是否有照片
    $("#hasPhoto").click(function(){
        boxoption(this,chkphoto_open_url,'chkphoto_open','1');
    });
    //受否有工作经验
    $("#experienced").click(function(){
        boxoption(this,haveworkexp_url,'haveworkexp','1');
    });

    //排序
    var sortdesc = [
        {"value":0,"text":"智能排序"},
        {"value":1,"text":"时间排序"}
    ];
    $(".resumesList .top .sequence a").click(function(){
        var val = $(this).attr('data-value');
        person_jump(sortdesc_url,'sortdesc',val);
    });

    //简历checkbox全选
    $("#selectAll").click(function(){
        if($(this).attr('checked') == 'checked'){
            $(".resumesList .lists li .selectBtn").find("[type='checkbox']").attr("checked",'true');//全选
        }else{
            $(".resumesList .lists li .selectBtn").find("[type='checkbox']").removeAttr("checked");//取消全选
        }
    });
    //单选及多选
    $(".resumesList .lists li .selectBtn").find("[type='checkbox']").click(function() {
        if ($(this).attr('checked') != 'checked') {
            $(this).removeAttr("checked");
        } else {
            $(this).attr("checked", 'true');
        }
    });
    //批量浏览简历
    $("#seeResumes").click(function(){
        var str = "";
        //生成链接地址
        var all_length = $(".resumesList .lists li .selectBtn").find("[type='checkbox'][checked]").length;
        i = 1;
        $(".resumesList .lists li .selectBtn").find("[type='checkbox'][checked]").each(function () {
            if(i == 1){
                first_uid = $(this).val();
            }
            if(i == all_length){
                str += $(this).val();
            }else{
                str += $(this).val()+",";
            }
            i++;
        });
        if(str!=''){
            window.open("/resume_"+first_uid+".html?suid="+str);
        }else{
            layer.tips('对不起，您还未选择任何简历，请选择后再浏览。', $(this), {
                tips: [1, '#333'],
                time: 3000
            });
        }
    });


});

//筛选栏中下拉框选择后执行操作
function person_jump(linkurl,define_link,val){
    var exl="?";
    if(linkurl.indexOf("?") > 0 ){
        exl='&';
    }
    location.href=linkurl+exl+define_link+'='+val;
}

//checkbox  点击事件
function boxoption(othis,url,name,val){
    var exl="?";
    if(url.indexOf("?") > 0 ){
        exl='&';
    }

    if($(othis).attr('checked')=='checked'){
        location.href=url+exl+name+'='+val;
    }else{
        location.href=url+exl;
    }
}


